﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;

namespace Epam.PhotoGallery.Site.Helpers
{
	public abstract class HeaderItemsCollection
	{
		private readonly string _format;
		private readonly IList<string> _items;
		private const string UC = "<%= Url.Content(\"";
		private const string UCTale = "\") %>";

		public HeaderItemsCollection(string format)
		{
			_format = format;
			_items = new List<string>();
		}

		public void Add(string url)
		{
			if (!_items.Contains(url))
			{
				_items.Add(url);
			}
		}

		public IHtmlString Render()
		{
			var sb = new StringBuilder();

			foreach (var item in _items)
			{
				var conectionString = string.Concat(item);

				var fmt = string.Format(_format, conectionString);
				
				sb.AppendLine(fmt);
			}

			return new HtmlString(sb.ToString());
		}
	}
}